package com.cloud.dao.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Component;

import com.cloud.core.BaseDao;
import com.cloud.dao.CaseBean;
import com.cloud.dao.PictureBean;

/**
 * 1Cloud1
 * @author Administrator
 * @since 2015-12-4
 * @version 1.0 
 */
@Component("CaseDao")
public class CaseDao extends BaseDao {
	
	public List<CaseBean> getCaseList(CaseBean bean){
		SqlSession session = super.getInstance(true);
		List<CaseBean> beanList = null;
		try {
			beanList = session.selectList("case.list", bean);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			session.close();
		}
		return beanList;
	}
	
	public List<PictureBean> getCasePictureList(String case_id){
		SqlSession session = super.getInstance(true);
		List<PictureBean> beanList = null;
		try {
			beanList = session.selectList("case.picturelist", case_id);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			session.close();
		}
		return beanList;
	}
	
	public void addCase(CaseBean bean){
		SqlSession session = super.getInstance(true);
		session.insert("case.insert", bean);
		session.close();
	}
	
	public void addCasePicture(CaseBean bean){
		SqlSession session = super.getInstance(true);
		session.insert("case.insertPicture", bean);
		session.close();
	}
	
	public void updateCase(CaseBean bean){
		SqlSession session = super.getInstance(true);
		session.update("case.update", bean);
		session.close();
	}
	
	public void deleteCase(CaseBean bean){
		SqlSession session = super.getInstance(true);
		session.delete("case.delete", bean);
		session.close();
	}
	
	public void deletePicture(CaseBean bean){
		SqlSession session = super.getInstance(true);
		session.delete("case.deletePicture", bean);
		session.close();
	}
}
